#ifndef DV_SOURCE_H
#define DV_SOURCE_H
#include "dvpacketqueue.h"
#include <ThreadUtil.h>
#include <vector>
using namespace std;

class IDVDestination;

class IDVSource
{
public:
	IDVSource();
	virtual ~IDVSource();
	virtual bool AddDestination(IDVDestination* pDest);
	virtual bool Start();
	virtual bool Stop();
	virtual bool IsRunning();
protected:
	virtual void* SourceProc(void*);
	virtual bool Init();
	virtual DVPacket GetPacket() = 0;
	virtual bool Cleanup();
	virtual packet_iterator GetFirstPacket();
	virtual char* GetNextPacket(packet_iterator& it, u_int32_t& length, IPEndPoint& ep, u_int32_t& pkt_left);
	virtual bool ReleaseIterator(packet_iterator it);
	virtual u_int32_t GetPacketCount();
	virtual double GetTraffic();
protected:
	vector<IDVDestination*> dests;
	DVPacketQueue			pktQueue;
	thread_t				thread;
	bool					quitThread;
	SimpleEvent				evtThreadQuit;
	double					traffic;
	friend class IDVDestination;
};


#endif // !define (DV_SOURCE_H)

